package chapter12

/**
  * @Copyright: Shanghai Definesys Company.All rights reserved.
  * @Description:
  * @author: chuhaitao
  * @since: 2019/1/14 21:27
  * @history:
  *          1.2019/1/14 created by chuhaitao
  */
object UpperDemo {


  def main(args: Array[String]): Unit = {


    var list01 = List("Ajkdlf", "sdfdf", "Uer")
    //转化大写
    var list02 = list01.map(a => {
      a.toUpperCase
    })
    //扁平化
    var list03 = list01.flatMap(a => {
      a
    })
    println(list02)
    println(list03)

    //过滤
    var list04 = list01.filter(a => {
      a.startsWith("A")
    })

    println("list04" + list04)

    //化简
    var list06 = List[Int](1, 2, 3, 4, 454, 12, 123);
    var res = list06.reduceLeft((n1: Int, n2: Int) => {
      n1 + n1
    })
    println("res:" + res)


    var min = list06.reduceLeft((n1: Int, n2: Int)=> {
      if(n1 >= n2) {
        n2
      }else {
        n1
      }

    })

    println("min:" + min)
  }

}
